package com.csdj.youxi.common;

import org.apache.log4j.Logger;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class QuanJuExecption {
    private Logger log = Logger.getLogger("exception");

    @ResponseBody
    @ExceptionHandler(value = Exception.class)//可以处理异常的类型
    public WebResult exception(Exception e){//异常
        e.printStackTrace();
        log.error("error",e);
        return new WebResult(MessageCode.FAIL);
    }

    /*@InitBinder
    public void bind(WebDataBinder dataBinder){
        dataBinder.addCustomFormatter(new TAddressFormatter());
    }*/
}
